<?php
/**
 * Created by 项目.
 * User: xuguopeng
 * Date: 2020-06-23
 * Time: 19:10
 */

namespace app\api\validate\order;


use app\api\validate\BaseValidate;

class CheckStaffOrder extends BaseValidate
{
    protected $rule = [
        'order_id' => 'require|isPositiveInteger',
        'clean' => 'checkClean',
        'price' => 'require'
    ];


    protected $message = [
        'order_id' => '请选择正确的订单',
        'clean' => '请输入正确取衣清单内容',
        'price' => '请输入洗衣总金额',
    ];


    // 基础信息
    protected function checkClean($value)
    {
        if(count($value) > 0) {
            foreach ($value as $v) {
                if(!$this->isPositiveInteger($v['number'])) {
                    return false;
                }
                if(strlen($v['name']) >= 30 || strlen($v['name']) == 0) {
                    return false;
                }
            }
        }
        return true;
    }
}